﻿using System;
using System.Net;
using System.Runtime.Serialization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace Components.ETL
{
    [DataContract]
    public class CitationParserOutput : ResultBase
    {
        #region props
        [DataMember]
        public int TotalRecords { get; set; }
        [DataMember]
        public int TotalCitations { get; set; }
        #endregion

        #region ctor
        /// <summary>
        /// 
        /// </summary>
        public CitationParserOutput()
            : base(Guid.Empty, Guid.Empty)
        {
            this.TotalRecords = 0;
            this.TotalCitations = 0;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="componentID"></param>
        /// <param name="jobTicketID"></param>
        /// <param name="totalRecords"></param>
        /// <param name="totalCitations"></param>
        public CitationParserOutput(Guid componentID, Guid jobTicketID,
            int totalRecords, int totalCitations)
            : base(componentID, jobTicketID)
        {
            this.TotalRecords = totalRecords;
            this.TotalCitations = totalCitations;
        }
        #endregion

        #region Overrides of ResultBase

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override XElement Serialize()
        {
            XElement xe = base.Serialize();
            xe.Add(new XAttribute("TotalRecords", this.TotalRecords.ToString()));
            xe.Add(new XAttribute("TotalCitations", this.TotalCitations.ToString()));

            return xe;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="xe"></param>
        /// <returns></returns>
        public override ResultBase Instantiate(XElement xe)
        {
            CitationParserOutput output = (CitationParserOutput)base.Instantiate(xe);

            output.TotalRecords = int.Parse(xe.Attribute("TotalRecords").Value);
            output.TotalCitations = int.Parse(xe.Attribute("TotalCitations").Value);

            return output;
        }

        #endregion
    }
}
